package com.online.findagentserver.slave1;

import com.online.findagentserver.domain.Ssc;
import org.apache.ibatis.annotations.*;

import java.sql.Timestamp;
import java.util.List;

/**
 * @Author: liuqing
 * @Despriction:
 * @Date:Created in 2018/4/28 15:29
 * @Modify By:
 */
@Mapper
public interface Ssc1Mapper {
    /**
     * 新增ssc记录
     *
     * @param ssc
     * @return
     */
    @Insert("INSERT INTO ols_ssc (agent_id,agent_name,session_id,company_id,create_time) " +
            "VALUES (#{agentId},#{agentName},#{sessionId},#{companyId},#{createTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertSSc(Ssc ssc);

    /**
     * 查询坐席id
     *
     * @param sessionId
     * @return
     */
    @Select("select agent_id from ols_ssc where session_id = #{sessionId}")
    List<Integer> getSsc(@Param("sessionId") int sessionId);

    /**
     * 查询最后一次交互的session id
     *
     * @param openId
     * @return
     */
    @Select("select id from ols_session where open_id = #{openId} ORDER BY id DESC LIMIT 1")
    Integer getSessionId(@Param("openId") String openId);

    /**
     * 查询最后一次交互的坐席ID
     *
     * @param sessionId
     * @return
     */
    @Select("select id from ols_ssc where session_id = #{sessionId} ORDER BY id DESC LIMIT 1")
    Integer getAId(@Param("sessionId") int sessionId);
}
